#pragma once

#include "Common.h"

class PageCache
{
public:
	static PageCache* GetInstance()
	{
		return &_sInst;
	}

	Span* NewSpan(size_t size);
	void ReleaseSpanToPage(Span* span);
	Span* MapObjectToSpan(void* obj);
private:
	PageCache() {}
	PageCache(const PageCache&) = delete;
	PageCache& operator=(const PageCache&) = delete;

	SpanList _spanLists[NPAGELIST];
	static PageCache _sInst;
	std::unordered_map<PAGE_ID, Span*> _id_span_map;
public:
	std::mutex _page_mtx;
};